home *** CD-ROM | disk | FTP | other *** search
- /****
- * CWaveDoc.c
- *
- * © Symantec - USE FOR TEST ONLY! - (stripped down from Starter appl)
- *
- ****/
-
- #include <Global.h>
- #include <Commands.h>
- #include <CApplication.h>
- #include <CBartender.h>
- #include <CDataFile.h>
- #include <CDecorator.h>
- #include <CDesktop.h>
- #include <CError.h>
- #include <CPanorama.h>
- #include <CPane.h>
-
- #include "CWaveDoc.h"
- #include "CWavePanel.h"
-
-
- #define mainWindID 500 /* Resource IDs */
- #define mainPaneID 500
-
- #define panelPaneID 501
- #define scopePaneType 'Pane'
- #define scopePaneID 502
-
-
- extern CApplication *gApplication; /* The application */
- extern CBartender *gBartender; /* The menu handling object */
- extern CDecorator *gDecorator; /* Window dressing object */
- extern CDesktop *gDesktop; /* The enclosure for all windows */
- extern CBureaucrat *gGopher; /* The current boss in the chain of command */
- extern OSType gSignature; /* The application's signature */
- extern CError *gError; /* The global error handler */
-
- /* IWaveDoc */
-
- void CWaveDoc::IWaveDoc(CBureaucrat *aSupervisor, Boolean printable)
-
- {
- CDocument::IDocument(aSupervisor, printable);
- }
-
-
- /* NewFile */
-
- void CWaveDoc::NewFile(void)
-
- {
- BuildWindow(NULL);
- itsWindow->Select();
- }
-
-
- /* OpenFile */
-
- void CWaveDoc::OpenFile(SFReply *macSFReply)
-
- {
- CDataFile *theFile;
- Handle theData;
- Str63 theName;
- OSErr theError;
-
- theFile = new(CDataFile);
- theFile->IDataFile();
- theFile->SFSpecify(macSFReply);
- itsFile = theFile;
- theError = theFile->Open(fsRdWrPerm);
- if (!gError->CheckOSError(theError)) {
- Dispose();
- return;
- }
- gApplication->RequestMemory(FALSE, FALSE);
- theFile->ReadAll(&theData);
- if (theData == NULL) {
- gError->CheckOSError(MemError());
- Dispose();
- return;
- }
- BuildWindow(theData);
- DisposHandle(theData);
- itsFile->GetName(theName);
- itsWindow->SetTitle(theName);
- itsWindow->Select();
- }
-
-
-
- /** BuildWindow, used by NewFile() and OpenFile(), display theData **/
-
- void CWaveDoc::BuildWindow (Handle theData)
- {
- CPane *mainPane;
- CWavePanel *panelPane;
- CPane *scopePane;
-
- Rect r;
-
- itsWindow = new(CWindow); /*create main window*/
- itsWindow->IWindow(mainWindID,FALSE,gDesktop,this);
-
- mainPane = new(CPane); /*create main pane*/
- mainPane->IViewRes('Pane',mainPaneID,itsWindow,this);
- mainPane->FitToEnclosure(TRUE,TRUE);
-
- mainPane->GetFrame(&r); /*adjust window to pane*/
- topLeft(r) = botRight(r); /*min size = max size*/
- itsWindow->SetSizeRect(&r);
- itsWindow->ChangeSize(r.right,r.bottom);
-
- panelPane = new(CWavePanel); /*create control panel pane*/
- panelPane->IWavePanel(panelPaneID,mainPane,this);
-
- scopePane = new(CPane); /*create oscilloscope pane*/
- scopePane->IViewRes(scopePaneType,scopePaneID,mainPane,this);
-
- itsMainPane = mainPane; /*print: all panes*/
- itsGopher = panelPane; /*send cmds to ctrl panel*/
-
- gDecorator->PlaceNewWindow(itsWindow); /*ok, place window*/
- }
-
-
- /* DoSave */
-
- Boolean CWaveDoc::DoSave(void)
-
- {
- if (itsFile == NULL)
- return(DoSaveFileAs());
- else {
- dirty = FALSE; /* Document is no longer dirty */
- gBartender->DisableCmd(cmdSave);
- return(TRUE); /* Save was successful */
- }
- }
-
-
- /* DoSaveAs */
-
- Boolean CWaveDoc::DoSaveAs(SFReply *macSFReply)
-
- {
- if (itsFile != NULL)
- itsFile->Dispose();
- itsFile = new(CDataFile);
- ((CDataFile *)itsFile)->IDataFile();
- itsFile->SFSpecify(macSFReply);
- itsFile->CreateNew(gSignature, 'TEXT');
- itsFile->Open(fsRdWrPerm);
-
- itsWindow->SetTitle(macSFReply->fName);
-
- return( DoSave() );
- }
-
-
- /* DoRevert */
-
- void CWaveDoc::DoRevert(void)
-
- {
- }
-